<?php include  APP_PATH.'../template/public/header.php'?>
<aside class="main-sidebar">
    <section class="sidebar">
        <?php include APP_PATH.'../template/public/navigation.php'?>
    </section>
</aside>
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            {$title}
        </h1>

        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> {$title}</a></li>
        </ol>
    </section>
    <section class="content">
        <div class="box box-default">
            <div class="box-body" style="font-size: 12px;">
                <div style="margin-bottom: 25px">
                    <label class="radio-inline">
                        登录方式:
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="optionsRadiosinline" id="user" value="option1" checked>账号登录
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="optionsRadiosinline" id="phone"  value="option2">手机验证登录
                    </label>
                 </div>
                <div id="cc">
                    <div style="margin-bottom: 25px">
                        <label class="radio-inline">
                            账户名:
                        </label>
                        <label class="radio-inline">
                            <?php $user=session('user');echo $user['username'];?>
                        </label>
                    </div>
                    <div id="pwd_btn" style="margin-bottom: 25px">
                        <label class="radio-inline">
                            <button id="edit_pwd" class="btn btn-block btn-info ">修改密码</button>
                        </label>
                    </div>
                    <div id="pwd" class="layui-hide" style="margin-bottom: 25px;width: 40%">
                        <form class="layui-form " action="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">请输入当前密码：</label>
                                <div class="layui-input-inline">
                                    <input type="password" name="old_pwd"  placeholder="请输入原密码" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">请您输入新的密码：</label>
                                <div class="layui-input-inline">
                                    <input type="password" name="new_pwd" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">请再次输入新的密码：</label>
                                <div class="layui-input-inline">
                                    <input type="password" name="new_pwd_check" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
                                    <button class="layui-btn">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                <div id="dd" class="layui-hide">
                    <div id="" style="margin-bottom: 25px">
                        <label class="radio-inline">
                            绑定管理员手机号：
                        </label>
                        <label class="radio-inline">
                            <button id="add_phone" class="btn btn-block btn-info ">添加</button>
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
<?php include APP_PATH.'../template/public/footer.php'; ?>
<script>
    $('#phone').change(function () {
        $('#cc').addClass('layui-hide');
        $('#cc').removeClass('layui-show');
        $('#dd').removeClass('layui-hide');
        $('#dd').addClass('layui-show');
    });
    $('#user').change(function () {
        $('#dd').addClass('layui-hide');
        $('#dd').removeClass('layui-show');
        $('#cc').removeClass('layui-hide');
        $('#cc').addClass('layui-show');
    });
   $('#edit_pwd').click(function () {
       $('#pwd').removeClass('layui-hide');
       $('#pwd').addClass('layui-show');
   });
    layui.use(['form', 'layedit', 'laydate','upload','layer'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate
            ,upload = layui.upload;
       $('#add_phone').click(function () {
           layer.open({
               type: 1
               ,title: false //不显示标题栏
               ,closeBtn: false
               ,area: '300px;'
               ,shade: 0.8
               ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
               ,btn: ['确认', '取消']
               ,btnAlign: 'c'
               ,moveType: 1 //拖拽模式，0或者1
               ,content: '<div >' +
               '<form class="layui-form " action="">' +
               '<div class="layui-form-item">' +
               '<label class="layui-form-label">管理员手机号：</label>' +
               '<div class="layui-input-inline">' +
               '<input type="password" name="adv_pwd"  placeholder="请输入管理员手机号" autocomplete="off" class="layui-input">' +
               '</div>' +
               '<div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>' +
               '</div>' +
               '<div class="layui-form-item">' +
               '<label class="layui-form-label">验证码：</label>' +
               '<div class="layui-input-inline">' +
               '<input type="password" name="adv_pwd_check"  placeholder="请输入验证码" autocomplete="off" class="layui-input">' +
               '</div>' +
               '<button class="layui-layer-btn layui-word-aux">获取验证码</button>' +
               '</div>' +
               '</form>'
               +
               '</div>'
               ,success: function(layero){
                   var btn = layero.find('.layui-layer-btn');
                   btn.find('.layui-layer-btn0').attr({
                       href: 'http://www.layui.com/'
                       ,target: '_blank'
                   });
               }
           });
       });

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        //监听提交
        form.on('submit(demo1)', function(data){
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            if(data.field.new_pwd==data.field.new_pwd_check){
                $.post("{:url('edit_pwd')}", data.field, function (res) {
                    layer.close(loading);
                    if (res.code > 0) {
                        layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                            location.href = res.url;
                        });
                    } else {
                        layer.msg(res.msg, {time: 1800, icon: 2});
                    }
                });
            }else{
                layer.close(loading);
                layer.msg('两次输入密码不一致', {time: 1800, icon: 2});
            }
            return false;
        });
    });
</script>
</html>